package com.shujia.rec.controller;

import com.shujia.rec.domain.ContactEntity;
import com.shujia.rec.domain.ProductEntity;
import com.shujia.rec.service.ContactService;
import com.shujia.rec.service.ProductService;
import com.shujia.rec.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ContactController {

    @Autowired
    ContactService contactService;

    @Autowired
    private RecommendService RecommendService;

    @GetMapping("/listAll")
    public String listAll(@RequestParam("userId") String userId,  Model model) {

        List<ContactEntity> listAll = contactService.listAll(10);
        List<ContactEntity> topN = contactService.topN();
        //获取推荐列表
        List<ContactEntity> recList = RecommendService.getRecList(userId);

        model.addAttribute("userId", userId);
        model.addAttribute("listAll", listAll);
        model.addAttribute("recList", recList);
        model.addAttribute("topN", topN);

        return "user";
    }


}
